package org.linlinjava.litemall.wx.web;

import org.linlinjava.litemall.core.util.JacksonUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.SaleHistory;
import org.linlinjava.litemall.db.service.LitemallHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/wx/commodity")

@Validated
public class LitemallHistoryControllery {
    @Autowired
    private LitemallHistoryService historyService;

    @PostMapping("list")
    public Object queryByName(@RequestBody String body, HttpServletRequest request){
        String name = JacksonUtil.parseString(body, "name");
        SaleHistory saleHistory = historyService.queryByName(name);
        return ResponseUtil.ok(saleHistory);
    }
}
